package com.jiang.controller;

import cn.dsna.util.images.ValidateCode;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.jiang.controller
 * @Description:
 * @Date 2022/5/22 14:47
 */
@WebServlet("/code")
public class validetacode extends BaseServlet {

    public void createCode(HttpServletRequest request,HttpServletResponse response) throws IOException {
        //创建验证码
        ValidateCode code = new ValidateCode(200,50,1,10);
        //获取验证码
        String code1 = code.getCode();
        //将验证码写到域中
        request.getSession().setAttribute("code",code1);
        //将验证码写回去
        code.write(response.getOutputStream());
    }
}
